﻿using System;

namespace CannedHeater
{
    /// <summary>
    /// Events that ViewModels can attach to, to be notified when app is closed/deactivated (to save data)
    /// Note: No events for Launching/Activating, since ViewModels are not loaded in time to be notified of this event anyway
    /// </summary>
    public static class HostEvents
    {
        // Thanks to chibacity at http://stackoverflow.com/questions/4459247/notify-viewmodels-of-closing-the-program for inspiration

        public delegate void ClosingAppHandler(object sender, EventArgs args);
        public static event ClosingAppHandler ClosingApp;
        public static void RaiseClosingApp(object sender)
        {
            if (ClosingApp != null)
                ClosingApp(sender, null);
        }

        public delegate void DeactivatingAppHandler(object sender, EventArgs args);
        public static event DeactivatingAppHandler DeactivatingApp;
        public static void RaiseDeactivatingApp(object sender)
        {
            if (DeactivatingApp != null)
                DeactivatingApp(sender, null);
        }

    }
}
